<?php

namespace App\Http\Controllers\Dash;

use App\Http\Controllers\Controller;
use App\Model\Catalogo;
use App\Model\Tutorial;
use Illuminate\Http\Request;

class EnderecoController extends Controller
{
    public function index()
    {
        $data = Catalogo::all();
        return view('dash.endereco.index', compact('data'));
    }

    public function create()
    {
        return view('dash.endereco.create');
    }

    public function edit($id)
    {
        $data = Catalogo::find($id);
        return view('dash.endereco.edit', compact('data', 'id'));
    }


    public function store(Request $request)
    {
        $re = new Catalogo();
        $re->name = $request->name;
        $re->b64 = $request->b64;
        $re->save();
        return redirect(route('dash.endereco'));
    }

    public function update($id, Request $request)
    {
        $re = Catalogo::find($id);
        $re->name = $request->name;
        $re->b64 = $request->b64;
        $re->save();
        return redirect(route('dash.endereco'));
    }

    public function delete($id)
    {
        $re = Catalogo::find($id)->delete();
        return redirect(route('dash.endereco'))->with('success', $re);
    }
}
